package com.itbaizhan.springboottask;

import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
/*两个线程运行后，线程1会阻止线程二运行，创建线程池
* （ScheduledConfig）让它们在同的线程运行*/
@Component
public class MyTask3 {
    @Scheduled(cron="* * * * * *")
    public void task1() throws InterruptedException {
        System.out.println(Thread.currentThread().getId()+"线程任务1");
        Thread.sleep(5000);
    }
    @Scheduled(cron="* * * * * *")
    public void task2(){
        System.out.println(Thread.currentThread().getId()+"线程任务2");
    }
}
